package com.ogawa.chair7808.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by FHB on 2018/4/18.
 */
public class SoftApSucceedObserver {

    private static SoftApSucceedObserver mInst = null;
    private static Object mLock = new Object();

    private List<onSoftApLis> mOnSoftApListerner;

    private SoftApSucceedObserver(){
        mOnSoftApListerner = new ArrayList<>();
    }

    public static SoftApSucceedObserver getInst(){
        if(mInst == null){
            synchronized(mLock){
                if(mInst == null){
                    mInst = new SoftApSucceedObserver();
                }
            }
        }
        return mInst;
    }

    public void  registerObserver(onSoftApLis action){
        if(!mOnSoftApListerner.contains(action)){
            mOnSoftApListerner.add(action);
        }
    }

    public void removeObserver(onSoftApLis action){
        mOnSoftApListerner.remove(action);
    }


    public void noticeSoftApOk(){
        for (int i = 0; i < mOnSoftApListerner.size(); i++) {
            try {
                mOnSoftApListerner.get(i).isSoftApOk();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    public interface onSoftApLis {
        void isSoftApOk();


    }


}
